<template>
	<view class="box">
		<view class="card" v-for="(item,index) in downTaskList" :key="index">
			<view class="top">
				<view class="bookName">
					{{item.bookName}}
				</view>
			</view>
			<view class="end">
				<view class="left">
					<view class="downBox">
						<template v-if="item.downStatus==1">
							<view class="process" style="width:100%">

							</view>
						</template>
						<template v-if="item.downStatus==2">
							<view class="process" style="width:100%;background-color:red;">
						
							</view>
						</template>
						<template v-else>
							<template v-if="item.isStart">
								<view class="process" :style="{width:item.process!=0?item.process+'%':'0%'}">
								
								</view>
							</template>
							<template v-else>
								<view class="process" style="width: 0%;">
								
								</view>
							</template>
						</template>
					</view>
					<template v-if="item.isStart">
						<text>{{item.downingSize+'MB/'+item.totalSize+'MB'}}</text>
					</template>
				</view>
				<view class="right">
					<template v-if="item.isSign">
						<text>删除了</text>
					</template>
					<template v-else>
						<text v-if="item.downStatus==1">
							已下载
						</text>
						<text v-else-if="item.downStatus==2">
							下载失败
						</text>
						<text v-else>
							{{item.isStart?'正在下载':'准备下载'}}
						</text>
					</template>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapMutations,
		mapState,
		mapActions
	} from "vuex"
	export default {
		data() {
			return {
				list: []
			};
		},
		computed: {
			...mapState("txtDownTaskStore", ["downTaskList"])
		},
		created() {
			this["txtDownTaskStore/goodControl"]()
		},
		methods: {
			...mapActions(["txtDownTaskStore/goodControl"]),
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		.card {
			height: 140rpx;
			border-bottom: 1rpx solid #00aa00;
			padding: 20rpx 30rpx;
			box-sizing: border-box;
			background: linear-gradient(to top right, orange, red);

			.top {
				height: 50rpx;
				font-size: 34rpx;
				display: flex;
				color: #00aa00;
				font-style: italic;
				font-weight: bold;
			}

			.end {
				height: 50rpx;
				display: flex;
				align-items: center;

				.left {
					width: 70%;
					height: 50rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;
					font-size: 24rpx;

					.downBox {
						width: 47%;
						height: 20rpx;
						background-color: #fff;
						border-radius: 10rpx;

						.process {
							height: 100%;
							background-color: #ccc;
							border-radius: 10rpx;
						}
					}
				}

				.right {
					width: 30%;
					height: 50rpx;
					line-height: 50rpx;
					text-align: center;
					color: #ccc;
				}
			}
		}
	}
</style>